// pages/make/list/list.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		fwID: []
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		console.log(options)
		wx.request({
			url: getApp().globalData.http + 'action=getShopServer&shopid='+options.id,
			success: (e) => {
				console.log(e)
				this.setData({
					data: e.data.data
				})
			}
		})
	},
	li(e) {
		console.log(e.currentTarget.dataset.id)
		if (e.currentTarget.dataset.id == this.data.tat) {
			this.setData({
				tat: -1
			})
		} else {
			this.setData({
				tat: e.currentTarget.dataset.id
			})
		}
	},
	id(e) {
		this.setData({
			fwID: e.detail.value
		})
		console.log(e.detail.value)
		console.log(this.data.fwID)
	},
	sure() {
		let a = this.data.fwID
		a = a.join()
		let b = []
		console.log(a)
		wx.request({
			// url: getApp().globalData.http + 'action=getShopServer&shopid='+options.id,
			url: getApp().globalData.http + 'action=getServerTypeByID&typeid=' + a,
			success: (e) => {
				e.data.data.forEach(function(item, index) {
					b.push(item.Tname)
				})
				b = b.join()
				console.log(b)
				let pages = getCurrentPages(); // 当前页的数据，可以输出来看看有什么东西
				let prevPage = pages[pages.length - 2];
				console.log(pages)
				console.log(pages.length)
				console.log(pages[pages.length - 2])
				prevPage.setData({
					list: this.data.fwID,
					listItem: b
				})
				wx.navigateBack({
					delta: 1
				})
			}
		})
		
	}
})
